﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

using System.Text;
using PowerCreator.LMS.Web.Question;
using PowerCreator.LMS.Question.Entiry;
using PowerCreator.LMS.Common.Script;
using PowerCreator.LMS.Common.Utils;

public partial class sysadmin_QuestionManager_CombinationQuestion_Edit_mingci : PowerCreator.LMS.Web.Base.BasePage
{
    ManagerQuestion objQuestion = new ManagerQuestion();
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {

            string QuestionID = Base64.Decode(Request.QueryString["qid"].ToString());
            string FatherQuestionID = Base64.Decode(Request.QueryString["fthID"].ToString());
            ViewState["QuestionID"] = QuestionID;
            ViewState["FatherQuestionID"] = FatherQuestionID;
            ViewState["TypeID"] = 5;
           
            Pageload();
            InitPage();
        }
    }
    protected override void InitPage()
    {
        lab_TitleInfo.Text = GetLanageValueByKey("lab_AddQuestionInfo_danx_ContentTitle", PowerCreator.LMS.Language.LanagetItemType.Page);
        lab_QuestionCount.Text = GetLanageValueByKey("lab_AddQuestionInfo_danx_QuestionContent", PowerCreator.LMS.Language.LanagetItemType.Page);
        lab_RightAnswer.Text = GetLanageValueByKey("lab_AddQuestionInfo_danx_QuestionOption", PowerCreator.LMS.Language.LanagetItemType.Page);
        lab_RightAnswer.Text = GetLanageValueByKey("lab_AddQuestionInfo_danx_RightAnswer", PowerCreator.LMS.Language.LanagetItemType.Page);

        btnSave.Text = GetLanageValueByKey("btn_Save", PowerCreator.LMS.Language.LanagetItemType.Page);
        base.InitPage();
    }

    private void Pageload()
    {
        VOQuestion objQuestionInfo = new VOQuestion();
        objQuestionInfo = objQuestion.LoadQuestion(int.Parse(ViewState["QuestionID"].ToString()));
        ViewState["objQuestionInfo"] = objQuestionInfo;

        txtQuestionContent.Value = objQuestionInfo.QuestionContent;
        txtQuestionParse.Text = objQuestionInfo.QuestionParse;

    }

    protected void btnSave_Click(object sender, EventArgs e)
    {
        VOQuestion objQuestionInfo = new VOQuestion();
        objQuestionInfo = (VOQuestion)ViewState["objQuestionInfo"];
        //objQuestionInfo.FKQuestionCourseID = int.Parse(ViewState["FKQuestionCourseID"].ToString());
        //objQuestionInfo.QuestionCreateID = int.Parse(Session["UserID"].ToString());
        //info.DateCreated = DateTime.Now;

        objQuestionInfo.QuestionParse = txtQuestionParse.Text;
        //objQuestionInfo.QuestionDefaultScore = int.Parse(ViewState["QuestionDefaultScore"].ToString());
        //objQuestionInfo.QuestionDiffculty = int.Parse(ViewState["QuestionDiffculty"].ToString());
        //objQuestionInfo.QuestionKen = ViewState["QuestionDiffculty"].ToString();


        objQuestionInfo.QuestionContent = txtQuestionContent.Value;


        //objQuestionInfo.QuestionState = int.Parse(ViewState["QuestionState"].ToString());         //禁用1,启用2

        if (objQuestion.UpdateQuetion(objQuestionInfo))//更新试题信息
        {
            Script.ShowAndHistory(GetLanageValueByKey("Msg_ManagerQuestion_WorkOK", PowerCreator.LMS.Language.LanagetItemType.Page), -2);
        }
        else
        {
            Script.Alert(GetLanageValueByKey("Msg_ManagerQuestion_WorkNo", PowerCreator.LMS.Language.LanagetItemType.Page));
        }

    }
    protected void btnBack_Click(object sender, EventArgs e)
    {
        Script.RedirectURL("EditQuestionInfo_zuhe.aspx?qid=" + ViewState["FatherQuestionID"].ToString());
    }
}
